<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <title>Document</title>
</head>
<body>
<form id="form1" enctype="multipart/form-data">
    <input type="file" name="file"><br>
</form>
<button id="button">上传</button>


</body>
<script>
    $("#button").on('click',function(){
        var formData=new FormData($("#form1")[0])
        var str="杜"
        $.ajax({
            type: 'post',
            url: "http://localhost:8082/upload",
            data: formData,
            cache: false,
            processData: false,
            contentType: false,
            success:function (data){
                console.log(data)
            }
        })
    })
</script>
</html>